package rev1;

import java.util.StringTokenizer;

public class DHTUtil {
	
	public static String parseNodeHash(String in)
	{
		StringTokenizer st = new StringTokenizer(in, "::");
		if (st.hasMoreTokens()) {
			return st.nextToken();
		}
		else throw new RuntimeException("Error parsing key parseValue");
	}
		
	public static String parseKey(String in)
	{
		StringTokenizer st = new StringTokenizer(in, "::");
		if (st.hasMoreTokens()) {
			String node = st.nextToken();
			String key = st.nextToken();
			//String val = st.nextToken();
			return key;
		}
		else throw new RuntimeException("Error parsing key parseValue");
	}
	
	public static String parseValue(String in)
	{
		StringTokenizer st = new StringTokenizer(in, "::");
		if (st.hasMoreTokens()) {
			String node = st.nextToken();
			String key = st.nextToken();
			String val = st.nextToken();
			return val;
		}
		else throw new RuntimeException("Error parsing key parseValue");
	}
}
